package com.lg.happyfarmer.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.lg.happyfarmer.R;
import com.lg.happyfarmer.adapter.MyViewPagerAdapter;
import com.lg.happyfarmer.base.BaseActivity;
import com.lg.happyfarmer.base.BaseUtil;
import com.lg.happyfarmer.snackbar.BaseTransientBottomBar;
import com.lg.happyfarmer.snackbar.TopSnackBar;
import com.lg.happyfarmer.untils.UserUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 登陆方式选择
 * Created by Torres on 2018/3/31 0031.
 */

public class SelectLoginActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.ib_back)
    ImageButton ib_back;
    @Bind(R.id.fl_error)
    FrameLayout fl_error;
    @Bind(R.id.fl_title)
    FrameLayout fl_title;
//    @Bind(R.id.btn_phone)
//    Button btn_phone;
//    @Bind(R.id.btn_third)
//    Button btn_third;
//    @Bind(R.id.ll_method)
//    LinearLayout ll_method;
//    @Bind(R.id.ll_third)
//    LinearLayout ll_third;
//    @Bind(R.id.btn_wx)
//    Button btn_wx;
//    @Bind(R.id.btn_qq)
//    Button btn_qq;
//    @Bind(R.id.btn_back)
//    Button btn_back;
    @Bind(R.id.viewPager)
    ViewPager viewPager;
    private int status = 0;//1 正确 0 错误
    private String temp;
    private List<View> datas;
    private MyViewPagerAdapter myViewPagerAdapter;
    private Button btn_back,btn_qq,btn_wx,btn_third,btn_phone;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_selectlogin);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
        initDatas();//初始化数据集
        myViewPagerAdapter=new MyViewPagerAdapter(datas);
        viewPager.setAdapter(myViewPagerAdapter);//设置适配器

    }
    private void initDatas() {
        datas=new ArrayList<>();
        View view1= LayoutInflater.from(this).inflate(R.layout.pager_loginstyle,null);
        View view2= LayoutInflater.from(this).inflate(R.layout.pager_thirdlogin,null);
        btn_phone= (Button) view1.findViewById(R.id.btn_phone);
        btn_third= (Button) view1.findViewById(R.id.btn_third);
        btn_back= (Button) view2.findViewById(R.id.btn_back);
        btn_qq= (Button) view2.findViewById(R.id.btn_qq);
        btn_wx= (Button) view2.findViewById(R.id.btn_wx);
        btn_third.setOnClickListener(this);
        btn_phone.setOnClickListener(this);
        btn_back.setOnClickListener(this);
        btn_qq.setOnClickListener(this);
        btn_wx.setOnClickListener(this);
        datas.add(view1);
        datas.add(view2);
    }

    @Override
    protected void callBeforeDataBack(HemaNetTask netTask) {
        super.callBeforeDataBack(netTask);
    }

    @Override
    protected void callAfterDataBack(HemaNetTask netTask) {
        super.callAfterDataBack(netTask);
    }

    @Override
    protected void callBackForServerSuccess(HemaNetTask netTask, HemaBaseResult baseResult) {
        super.callBackForServerSuccess(netTask, baseResult);
    }

    @Override
    protected void callBackForServerFailed(HemaNetTask netTask, HemaBaseResult baseResult) {
        super.callBackForServerFailed(netTask, baseResult);
    }

    @Override
    protected void callBackForGetDataFailed(HemaNetTask netTask, int failedType) {
        super.callBackForGetDataFailed(netTask, failedType);
    }

    @Override
    protected void findView() {

        super.findView();
    }

    @Override
    protected void getExras() {
        super.getExras();
    }

    @Override
    protected void setListener() {
        super.setListener();
        ib_back.setOnClickListener(this);
//        btn_back.setOnClickListener(this);
//        btn_third.setOnClickListener(this);
//        btn_phone.setOnClickListener(this);
//        btn_qq.setOnClickListener(this);
//        btn_wx.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent it = null;
        switch (view.getId()) {
            case R.id.ib_back:
                finish();
                break;
            case R.id.btn_third:
//                ll_method.setVisibility(View.GONE);
//                ll_third.setVisibility(View.VISIBLE);
//                btn_back.setVisibility(View.VISIBLE);
                viewPager.setCurrentItem(1);
                break;
            case R.id.btn_phone:
                it = new Intent(mContext, LoginActivity.class);
                startActivity(it);
                break;
            case R.id.btn_back:
//                btn_back.setVisibility(View.GONE);
//                ll_third.setVisibility(View.GONE);
//                ll_method.setVisibility(View.VISIBLE);
                viewPager.setCurrentItem(0);
                break;
            case R.id.btn_qq:
            case R.id.btn_wx:
                it = new Intent(mContext, SexSelectActivity.class);
                startActivity(it);
                break;
        }
    }
}
